
class Phoen():

    def __init__(self,color,price,band):
        self.color = color
        self.price = price
        self.band = band


phoen = Phoen('彩色',1600,'oppo')
# 得到指定属性，没有指定属性但有默认值就返回默认值，没有属性也没有默认值就报错
print(getattr(phoen,'band'))
print(getattr(phoen,'xh','reno'))

# 判断是否有这个属性
print(hasattr(phoen,'color'))
print(hasattr(phoen,'xh'))

# 设置属性，有就修改，没有就创建
setattr(phoen,'xh','reno9')
print(getattr(phoen,'xh'))
setattr(phoen,'color','红色')
print(getattr(phoen,'color'))

# 删除属性，没有就报错AttributeError
delattr(phoen,'color')
# print(getattr(phoen,'color'))

